package com.example.test_demo.test;

import com.alibaba.fastjson.JSONObject;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: test
 * @description:
 * @author: yanghua
 * @create: 2021-07-15 15:42
 **/
public class Json {
    public static void main(String[] args) {
        //String str ="{\"market_id\":\"1\",\"period\":\"Contract Month\",\"commodity_id\":\"01000001743\",\"price_source_id\":\"99\",\"h_l\":\"SMP\"}";
        //String str ="{\"average_pricing_detail\":{\"five_fire_balls\":{\"commodity\":\"Brent Blend\",\"price_source\":\"EXCHANGE\",\"market\":\"ICE\",\"h_l\":\"SMP\",\"price_term\":\"\",\"average\":\"\",\"benchmark_id\":\"21\",\"period\":\"1st NRBY\"},\"name1\":\"ICE Brent 1st line\",\"shortcut\":\"/Brent Blend/EXCHAN,GE/1st NRBY/1st NRBY/SMP\",\"normalnumber\":-7.85,\"gjnumber\":null,\"phy_common_currency\":\"USD\",\"phy_uom\":\"BBL\",\"mark\":\"-\",\"number0\":7.85,\"osp\":0,\"freight\":0,\"insurance\":0,\"apiAdj\":0,\"sAdj\":0,\"type\":\"average\",\"priceType\":\"fixed month\",\"priceMonth\":\"202001\",\"da,te1\":\"Jan/01/2020\",\"date2\":\"Jan/31/2020\"}}";
        String str ="{\"insurance\":0,\"da,te1\":\"Jan/01/2020\",\"sAdj\":0,\"five_fire_balls\":{\"market\":\"ICE\",\"commodity\":\"Brent Blend\",\"average\":\"\",\"period\":\"1st NRBY\",\"h_l\":\"SMP\",\"price_term\":\"\",\"price_source\":\"EXCHANGE\",\"benchmark_id\":\"21\"},\"number0\":7.85,\"freight\":0,\"priceType\":\"fixed month\",\"date2\":\"Jan/31/2020\",\"apiAdj\":0,\"type\":\"average\",\"osp\":0,\"normalnumber\":-7.85,\"phy_uom\":\"BBL\",\"shortcut\":\"/Brent Blend/EXCHAN,GE/1st NRBY/1st NRBY/SMP\",\"phy_common_currency\":\"USD\",\"name1\":\"ICE Brent 1st line\",\"mark\":\"-\",\"priceMonth\":\"202001\"}";
        //String str ="{\"common_day_pricing\":false,\"quotations\":[{\"vol\":\"-100\",\"uom\":\"%\",\"premium\":\"\",\"contract\":{\"market_id\":3,\"period\":\"Contract Month\",\"commodity_id\":\"01000001517\",\"price_source_id\":99,\"h_l\":\"CLOSE\"},\"term\":{\"type\":\"none\"},\"benchmark_id\":5,\"benchmark\":\"NYMEX WTI\"},{\"vol\":\"100\",\"uom\":\"%\",\"premium\":\"\",\"contract\":{\"market_id\":601,\"period\":\"1st NRBY\",\"commodity_id\":\"01000000930\",\"price_source_id\":12,\"h_l\":\"CLOSE\"},\"term\":{\"type\":\"relative\",\"detail\":{\"day_type\":\"price days\",\"for\":\"accumulation period\",\"period\":\"roll date\",\"day_relation\":\"before\",\"type\":\"rolling\",\"day\":\"1\"}},\"benchmark_id\":26,\"benchmark\":\"Argus WTI Houston 1st line\"}]}";
        Map<String,Object> map = JSONObject.parseObject(str, Map.class);
        for (Map.Entry<String,Object> entry : map.entrySet()) {

            System.out.println("Key = " + entry.getKey() );
            System.out.println(" Value = " + entry.getValue());

        }
//        List<Map> map2 = JSONObject.parseArray("[" +str+ "]", Map.class);
//        map2.stream().forEach(ss->{
//            System.out.println("111 = "+ss.values());
//
//        });


    }
}
